package me.j360.springboot.simple.service.impl;

import me.j360.springboot.simple.entity.User;
import me.j360.springboot.simple.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;

/**
 * Created with springbootweb -> me.j360.springboot.simple.service.impl.
 * User: min_xu
 * Date: 2015/7/29
 * Time: 11:03
 * 说明：
 */
@Service
@Transactional(propagation= Propagation.REQUIRED)
public class UserServiceImpl implements UserService {

    @Autowired
    private EntityManagerFactory entityManagerFactory;

    public void insert(User user) {
        entityManagerFactory.createEntityManager().persist(user);
    }

}
